from sklearn.neighbors import KNeighborsClassifier

# 1.构造数据
x=[[0],[1],[2],[3]]
y=[0,0,1,1]

# 2.训练模型
# 2.1实例化
estimator = KNeighborsClassifier(n_neighbors=2)

# 2.2 调用fit方法进行训练
estimator.fit(x,y)

# 3.数据预测
result = estimator.predict([[0]])
print(result)

result1 = estimator.predict([[100]])
print(result1)


